<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<%@ taglib prefix ="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<%@ include file="/common/common-css.jsp"%>
		
		<link rel="stylesheet" href="/loan_manager/css/common-loading.css">
		
		<style>
			#jquery-table td {
				cursor: pointer !important
			}
			
			.productthumbnail {
				width: 100px;
				height: 100px;
			}
			
			@media (min-width: 768px) and (max-width: 1200px) {
				.backup-text {
					width: 100px !important;
				}
			}
		</style>
	</head>
	<body  class="no-skin">
		<%@ include file="/common/common-loading.jsp"%>
		<div class="page-content">
			<div class="page-header" style="margin-bottom:0px;padding-bottom:10px;">
				<h1 id="fu_name">
				</h1>
			</div>
			<form id="queryForm" method="post">
				<div class="page-content-area"> 
				<div class="row">
  					<div class="col-sm-12">
						<div class="widget-box" style="border:0px solid #ccc; border-top:none;border-bottom:none;margin-top:15px;">
							<hr style="margin-top:0px;margin-bottom:0x">
		
							<div class=" widget-body">
								<div class="widget-main" >
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right">产品：</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-12">
															<s:select id="product_id" name="product_id" list="%{paramsMap.productList}" listKey="activity_id" listValue="activity_name" 
															headerKey="" headerValue="全部" cssClass="form-control"></s:select>
													</div>
												</div>
											</div>
		
									</div><!-- /.widget-main -->
								</div><!-- /.widget-body -->
						</div><!-- /.widget-box -->
					</div><!-- /.col-sm-12 -->
					
					<div class="col-md-12 center">
						<div class="clearfix form-actions">
				
							<button class="btn btn-purple  no-border" type="button" name="btn-query" onclick="query_any()" id="btn-query" > 
								<i class="ace-icon fa fa-search icon-on-right bigger-110"></i> 
								查询 
							</button> 
							&nbsp;&nbsp;&nbsp;
							<button class="btn btn-grey  no-border" type="reset">
								<i class="ace-icon fa fa-undo icon-on-right bigger-110"></i>
								重置
							</button>
							
				 		 </div>
		  			 </div>
				
				</div><!-- /.row -->
									 
				<hr style="display:none;" id="delete_hr">
					<div class="row">
					<div class="col-xs-12">
						<table id="jquery-table" class="table table-striped table-bordered table-hover">
						</table>
					</div><!-- /.col -->
				</div><!-- /.row -->
			</div><!-- /.page-content-area -->
			</form>
		</div>
	</body>
</html>

<%@ include file="/common/common-js.jsp" %>
<!-- loading js -->
<script type="text/javascript" src="${ctx}/js/common-loading.js"></script>
<script type="text/javascript" src="${ctx}/js/call_func.js"></script>
<link rel="stylesheet" href="${ctx}/ace/css/just-tip.css"/>
<script src="${ctx}/ace/js/justTools.js"></script>

<!-- inline scripts related to this page -->
<script type="text/javascript">
		
    //【查询】按钮Click事件
	function query_any(){
	 	$("#output").removeAttr("style");
		if(jqTable != null){
			jqTable.fnDraw();
		} else {
			loaddata();
		}
		 $("#delete_btn").attr("style","display:block");
		 $("#delete_hr").attr("style","margin-top:0px;margin-bottom:20px;display:block");
	 };
	 
	 function getDetail($this){
		var activity_id = $this.getAttribute("activity_id");
		var external_num = $this.getAttribute("external_num");
		console.log(activity_id);
		console.log(external_num);
		openDialogWithRand("/externalpage/editorpage.action?activity_id="+ activity_id + "&external_num="+external_num+"",1000,400,"",function (data){});
	};
	
	 var jqTable = null;
	 var loaddata = function(){
		jQuery(function($) {
			jqTable = $('#jquery-table').dataTable( {
			    //数据列控制（包括对应返回JSON属性名称，对应表头列索引位置、数据转换封装等）
			    "columnDefs": [
					{	  
						  "title":'活动ID',
						  "name":"activity_id",
						  "data": "activity_id",
						  "targets": [0],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%",
					},
					{	  
						  "title":'logo',
						  "name":"logo",
						  "data": "logo",
						  "targets": [1],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%",
						  "render": function(value, type, row) { // 返回自定义内容
	  					      var star="<img src='"+value+"' style='height:50px;'/>";
	  						  return star;
						  }
					},
					{	  
						  "title":'活动名称',
						  "name":"activity_name",
						  "data": "activity_name",
						  "targets": [2],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%",
					},
					{	  
						  "title":'显示顺序',
						  "name":"external_num",
						  "data": "external_num",
						  "targets": [3],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%",
					},
					{	  
						  "title":'状态',
						  "name":"external_status",
						  "data": "external_status",
						  "targets": [4],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%",
						  "render":function(value,type,row){
							  if(1==value){
								  value="<font color='green'>上线中</font>";
							  }else{
								  value="<font color='red'>下线中</font>";
							  }
							  return value;
						  }
					},
					{	  
						  "title":'操作',
						  "name":"operation",
						  "data": "operation",
						  "targets": [5],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%",
						  "render": function(value, type, row) {
							  var statusClass = "btn-success";
							  if(row.activity_id)
									return "<a class='btn btn-send " + statusClass + " btn-sm' href='javascript:void(0)' activity_id=" + row.activity_id + " external_num=" + row.external_num + " onclick='getDetail(this)'>编辑</a>"	
						  }
					}
			  	],
				"sAjaxSource": ctx+"/externalpage/list.action?rand=" + Math.random(),
				"fnServerData": function ( sSource, aoData, fnCallback ) {//从服务器请求数据
			   			var data = $('#queryForm').serializeObject();
						
						data.aoData = JSON.stringify(aoData);
						$.ajax({
							"type": "POST",
							"dataType": 'json',
							"url": sSource,
							"data":data,
							"timeout":300000,
							"beforeSend": function() {
								// 显示loading
								showLoading();
							},
							"success": function(resp){
								console.info(resp);
								hideLoading();
								fnCallback(resp);
								initListPage();
								
							},		
							"error": function(XMLHttpRequest, textStatus, errorThrown) {
								alert('请求服务器错误,请刷新重试！！');//错误提示，包括服务器重启导致的session失效
							},			
							"complete": function () {
								hideLoading();
							}
					});
				},
				"sScrollXInner": "100%",
				"sScrollY": "100%",//如果不设置，IE会有问题
			    "aaSorting": [[2,"desc"]] //初始化加载，默认按第几列排序、排序方式（列从0开始计算）
			});
			
			
		});
	}
	
	
</script>